package jjn.round2;

/**
 * @author Jiang Jining
 * @since 2023-06-07 22:28
 */
public class LeetCode383_RansomNote {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] available = new int[26];
        for (char c : magazine.toCharArray()) {
            available[c - 'a']++;
        }
        for (char c : ransomNote.toCharArray()) {
            available[c - 'a']--;
            if (available[c - 'a'] < 0) {
                return false;
            }
        }
        return true;
    }
}
